<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">注册</h1>

		</header>
		<form class="mui-input-group" >
		<div class="mui-content" style="background: #fff;padding-bottom: 97%;">
			<div class="mui-input-row" style="margin-top: 11.9%;">
				<label>昵称：</label>
				<input id="nickname" type="text" placeholder="请输入昵称">
			</div>

			<div class="mui-input-row">
				<label>用户名：</label>
				<input id="uname" type="text" placeholder="请输入用户名">
			</div>
			<div class="mui-input-row">
				<label>密码：</label>
				<input id="pwd" type="password" placeholder="请输入密码">
			</div>
			<div class="mui-input-row">
				<label>手机号:</label>
				<input id="phone" type="tel" placeholder="请输入手机号">
			</div>
			<a class="mui-text-center mui-pull-right" style="font-size: 100%;margin-right: 2%;margin-top: 5%;">用户协议</a>
			<p class="mui-text-center" style="width: 100%;margin-top: 15%;font-size: 70%;">点击注册即表示您已阅读并同意用户协议。</p>
			<button id="btn_zhuce" type="button" class="mui-btn mui-btn-blue" style="width: 20%;margin-left: 40%;">注册</button>
		</div>
		</from>
		<script src="../js/mui.min.js"></script>
		<script src="../js/initData.js"></script>
		<script type="text/javascript">
			mui.init();
			document.getElementById("btn_zhuce").addEventListener("tap", function() {
				var nickname = document.getElementById("nickname").value;
				var uname = document.getElementById("uname").value;
				var pwd = document.getElementById("pwd").value;
				var phone = document.getElementById("phone").value;
				console.log("nickname="+nickname+",uname="+uname+",pwd="+pwd+",phone="+phone);
				mui.ajax('http://upday.ecst.com.cn:81/cyzsh/api/reg.do', {
					data: {
						"username": uname,
						"password": pwd,
						"nickname": nickname,
						"phone": phone
					},
					type: 'post', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						//服务器返回响应，根据响应结果，分析是否登录成功；
						console.log(data);
						if(JSON.parse(data).status == 200) {
							login(uname, pwd);
						} else {
							mui.toast(JSON.parse(data).msg);
						}
					},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						console.log(type);
					}
				});
			});
		</script>
	</body>

</html>